import { defineStore } from 'pinia'
import { getToken } from '@/utils/unit'
import crucial from '@/assets/staticdata/crucials'
import error from '@/assets/staticdata/errors'
import initBuryConfig, { BuryConfig } from '@xmon/bury/dist/config'

var bp: BuryConfig;
const useStore = defineStore('main', {
  state: () => ({
    count: getToken('count') || 0,
    crucials: crucial,
    errors: error,
    buryPayload: bp
  }),
  getters: {
    doubleCount(state) {
      return state.count * 2
    }
  },
  actions: {
    increment() {
      this.count++
    },
    setPayload(buryPayload: BuryConfig | any) {
      this.buryPayload = buryPayload
    },
    pushCrucial(c:crucial){
      this.crucials.push(c);
    },
    pushErrors(e:error){
      this.errors.push(e);
    }
  }
})

export default useStore